<template>
    <div id="app">
        <router-view></router-view>
    </div>
</template>


<script>
import speech from "@/utils/js/public/speech";

/* 公共js */
export default {
    name: 'App',
    data() {
        return {
            timers: [],
        }
    },

    mounted() {
        this.timers.push(
            setInterval(() => {
                // 渲染按钮点击样式事件
                this.$public.btnFocusBind()

                // 语音播报
                const needAudio = this.$store.state.UserModule.userInfo.needAudio
                document.querySelectorAll(".speech").forEach(ele => {
                    ele.onclick = function () {
                        if (needAudio) {
                            if (speech.speaking()) {
                                speech.cancel()
                            } else {
                                speech.play(this.innerText)
                            }
                        }
                    }
                })
            }, 500)
        )
    },

    beforeDestroy() {
        for (const timer of this.timers) {
            if (timer) clearInterval(timer)
        }
    }
}
</script>

<style lang="less" scoped>

</style>
